package tech.aistar.corejava.day02;

/**
 * Created by 李雨昂 on 2019/7/18.
 */
public class ChangeDataDemo {
    public static void main(String[] args) {
        //传统方法 - 使用第三方变量
        int a = 10;
        int b = 20;

//        int temp = a;
//        a = b;
//        b = temp;

        //不允许使用第三方变量
        //总结:一个数连续异或同一个数两次,结果是他本身!!!
//        a = a ^ b;// a = 10 ^ 20
//        b = a ^ b;// b = 10 ^ 20 ^ 20 = 10
//        a = a ^ b;// a = 10 ^ 20 ^ 10 = 20

        //自创的
        b = a^(a = b)^b;// b = 10 ^ 20 ^ 20 = 10
        System.out.println("a = " + a);
        System.out.println("b = " + b);

        System.out.println(-10>>>2);

        System.out.println(-10>>2);

    }
}
